package com.xiaotu.iterator;

import java.util.Iterator;

/**
 * @author 张晓
 * @create 2020-06-25 19:14
 */
public class ComputerColleage implements Colleage {

    Department[] departments;
    //保存当前数组对象的个数
    int numOfDepartment = 0;

    public ComputerColleage() {
        departments = new Department[5];
        addDepartment("Java专业","Java专业");
        addDepartment("Php专业","Php专业");
        addDepartment("大数据专业","大数据专业");
    }

    @Override
    public String getName() {
        return "计算机学院";
    }

    @Override
    public void addDepartment(String name, String desc) {
        Department department = new Department(name, desc);
        departments[numOfDepartment] = department;
        numOfDepartment++;
    }

    @Override
    public Iterator createIterator() {
        return new ComputerColleageIterator(departments);
    }
}
